﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 费率配置表
/// </summary>
[Table("RateConfig")]
[Index("AmountRangeStart", "AmountRangeEnd", Name = "idx_RateConfig_AmountRange")]
[Index("EffectiveTime", Name = "idx_RateConfig_EffectiveTime")]
[Index("MerchantId", Name = "idx_RateConfig_MerchantId")]
[Index("PaymentPlatformId", Name = "idx_RateConfig_PaymentPlatformId")]
[Index("Priority", Name = "idx_RateConfig_Priority", AllDescending = true)]
[Index("RateType", "BusinessType", Name = "idx_RateConfig_RateType_BusinessType")]
[Index("StoreId", Name = "idx_RateConfig_StoreId")]
public partial class RateConfig
{
    /// <summary>
    /// 费率配置ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 费率名称
    /// </summary>
    [StringLength(100)]
    public string RateName { get; set; } = null!;

    /// <summary>
    /// 费率类型：1=支付费率,2=提现费率,3=分账费率,4=退款费率
    /// </summary>
    public int RateType { get; set; }

    /// <summary>
    /// 业务类型：1=微信支付,2=支付宝,3=银行卡,4=现金,5=其他
    /// </summary>
    public int BusinessType { get; set; }

    /// <summary>
    /// 费率值（小数形式，如0.006表示0.6%）
    /// </summary>
    public decimal RateValue { get; set; }

    /// <summary>
    /// 最低费用（单位：分）
    /// </summary>
    public long? MinFee { get; set; }

    /// <summary>
    /// 最高费用（单位：分）
    /// </summary>
    public long? MaxFee { get; set; }

    /// <summary>
    /// 金额区间起始值（单位：分，null表示无限制）
    /// </summary>
    public long? AmountRangeStart { get; set; }

    /// <summary>
    /// 金额区间结束值（单位：分，null表示无限制）
    /// </summary>
    public long? AmountRangeEnd { get; set; }

    /// <summary>
    /// 商户ID（null表示全局费率）
    /// </summary>
    [StringLength(32)]
    public string? MerchantId { get; set; }

    /// <summary>
    /// 门店ID（null表示商户级费率）
    /// </summary>
    [StringLength(32)]
    public string? StoreId { get; set; }

    /// <summary>
    /// 支付平台ID（null表示通用费率）
    /// </summary>
    [StringLength(32)]
    public string? PaymentPlatformId { get; set; }

    /// <summary>
    /// 生效时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime EffectiveTime { get; set; }

    /// <summary>
    /// 失效时间（null表示永久有效）
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? ExpiryTime { get; set; }

    /// <summary>
    /// 优先级（数值越大优先级越高）
    /// </summary>
    public int Priority { get; set; }

    /// <summary>
    /// 备注说明
    /// </summary>
    [StringLength(500)]
    public string? Remark { get; set; }

    /// <summary>
    /// 扩展属性
    /// </summary>
    public string? ExtraProperties { get; set; }

    /// <summary>
    /// 并发标记
    /// </summary>
    [StringLength(40)]
    public string? ConcurrencyStamp { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 创建者ID
    /// </summary>
    [StringLength(32)]
    public string? CreatorId { get; set; }

    /// <summary>
    /// 最后修改时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? LastModificationTime { get; set; }

    /// <summary>
    /// 最后修改者ID
    /// </summary>
    [StringLength(32)]
    public string? LastModifierId { get; set; }

    /// <summary>
    /// 启用状态
    /// </summary>
    public int EnableStatus { get; set; }
}
